package com.fernfx.xingtan.main.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;

import com.fernfx.xingtan.R;
import com.fernfx.xingtan.common.base.BaseAdapter;
import com.fernfx.xingtan.utils.GlideUtil;

import java.util.List;

/**
 * Created by admin on 2018/8/23.
 *
 */

public class AddImgAdapter extends BaseAdapter {
    private Context context;
    private List<String> imagesList;

    public AddImgAdapter(Context context, List datas) {
        super(context, datas);
        this.context = context;
        this.imagesList = datas;
    }

    @Override
    public int getLayoutId() {
        return R.layout.adapter_upload_img_item;
    }

    @Override
    public Holder initHolder(View container) {
        ImageView uploadImgIv = container.findViewById(R.id.upload_img_iv);
        AddImgHolder addImgHolder = new AddImgHolder();
        addImgHolder.uploadImgIv = uploadImgIv;
        return addImgHolder;
    }

    @Override
    public void initItem(View view, Holder holder, int position) {
        AddImgHolder addImgHolder = (AddImgHolder)holder;
        String imageUrlText = imagesList.get(position);
        if (!TextUtils.isEmpty(imageUrlText)) {
            GlideUtil.loadImage(context,imageUrlText,addImgHolder.uploadImgIv);
        }
    }

    private class AddImgHolder extends Holder {
        ImageView uploadImgIv;
    }
}
